<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*,util.*"%>
<%@page import="bll.EnumName"%>
<%@page import="util.CacheUtil"%>
<%@page import="util.HtmlUtil"%>

<%
	AgendaItemModel obj;
	Object temp = request.getAttribute("agenda_item");
	if (temp != null) {
		try {
			obj = (AgendaItemModel) temp;
		} catch (Exception ex) {
			obj = new AgendaItemModel();
		}
	} else {
		obj = new AgendaItemModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Agenda Item</title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css"
	type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css"
	type="text/css" />

<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.min.js"></script>
<script src="js/jquery-1.5.1.min.js" type="text/javascript"
	language="javascript"></script>
<script src="js/jquery.hyjack.select.js" type="text/javascript"
	language="javascript"></script>
<script type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.min.js"></script>

<script type="text/javascript" src="js/jquery.ui.timepicker.js"></script>

<script src="js/jquery.hyjack.js" type="text/javascript"
	language="javascript"></script>
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Agenda Item</title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
	var requiredInputs = [['id_parent','id_parent_required'],['name','name_required'],['description','description_required'],['remark','remark_required'],['id_prev_item','id_prev_item_required'],['start_time','start_time_date_required', 'start_time','start_time_time_required'],['duration','duration_required'],['id_employee','id_employee_required'],['id_company','id_company_required'],['sound','sound_required'],['light','light_required'],['left_screen','left_screen_required'],['right_screen','right_screen_required'],['center_screen','center_screen_required'],['code','code_required'],['id_type','id_type_required'],['status','status_required'],['notification','notification_required']];
	var intInputs = [['id_agenda','id_agenda_invalid'],['id_parent','id_parent_invalid'],['id_prev_item','id_prev_item_invalid'],['duration','duration_invalid'],['id_employee','id_employee_invalid'],['id_company','id_company_invalid'],['id_type','id_type_invalid'],['status','status_invalid'],['notification','notification_invalid']];
	var doubleInputs = [];
	var dateInputs = [['start_time','start_time_date_invalid']];
	var timeInputs = [['start_time','start_time_time_invalid']];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<%@ include file="menu.jsp"%>
	<br />
	<table>
		<tr>
			<td>
				<form action="agendaitem?mode=insert" method="post"
					onSubmit="return checkInputs()"
					onreset="return confirm('Do you really want to reset the form?')">
					<table class="tblInput" border="1">
						<tr class="inputHeader">
							<td colspan="3" class="inputHeader">Create New Agenda Item</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Agenda</td>
							<td class="tdFieldInput"><select id="id_agenda"
								name="id_agenda" class="hyjack" disabled="disabled">
									<%=HtmlUtil.genModelSelect(CacheUtil.getAgendaList(), null,
					obj.getIdAgenda())%>
							</select> <%-- 					<input class="inputInt" type="text" id="id_agenda" name="id_agenda" maxlength="10" value="<%=obj.getIdAgenda()%>" /> --%>

							</td>
							<td class="tdErrMsg"><span id="id_agenda_required"
								class="errMsg" style="display: none;">Agenda is required</span>
								<span id="id_agenda_invalid" class="errMsg"
								style="display: none;">Agenda is invalid</span> <span
								id="id_agenda_error" class="errMsg"><%=obj.errMsgs.IdAgenda%></span>
							</td>
						</tr>

						<tr class="trField">
							<td class="tdFieldName">Start Time</td>
							<td class="tdFieldInput">
								<table class="tblDateTime">
									<tr class="trDateTime">
										<td class="tdDate"><input type="text" maxlength="10"
											class="inputDate" id="start_time_date" name="start_time_date"
											value="<%=DateTimeUtil.getDayString(obj.getStartTime())%>" />
											<input type="button" class="btnCalendar" value="..."
											onclick="javascript:displayDatePicker('start_time_date', this, dateFormat);" />
										</td>
										<td class="tdTime"><input type="text" maxlength="5"
											class="inputTime" id="start_time_time" name="start_time_time"
											value="<%=DateTimeUtil.getTimeString(obj.getStartTime())%>" />
										</td>
									</tr>
								</table></td>
							<td class="tdErrMsg"><span id="start_time_error"
								class="errMsg"><%=obj.errMsgs.StartTime%></span>
								<div class="divErr">
									<span id="start_time_date_required" class="errMsg"
										style="display: none;">Start Time's date is required</span>
								</div>
								<div class="divErr">
									<span id="start_time_time_required" class="errMsg"
										style="display: none;">Start Time's time is required</span>
								</div>
								<div class="divErr">
									<span id="start_time_date_invalid" class="errMsg"
										style="display: none;">Start Time's date is invalid</span>
								</div>
								<div class="divErr">
									<span id="start_time_time_invalid" class="errMsg"
										style="display: none;">Start Time's time is invalid</span>
								</div>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Duration</td>
							<td class="tdFieldInput"><input class="inputInt" type="text"
								id="duration" name="duration" maxlength="10"
								value="<%=obj.getDuration()%>" />
							</td>
							<td class="tdErrMsg"><span id="duration_required"
								class="errMsg" style="display: none;">Duration is
									required</span> <span id="duration_invalid" class="errMsg"
								style="display: none;">Duration is invalid</span> <span
								id="duration_error" class="errMsg"><%=obj.errMsgs.Duration%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput"><input class="inputText"
								type="text" id="name" name="name" maxlength="255"
								value="<%=obj.getName()%>" /></td>
							<td class="tdErrMsg"><span id="name_required" class="errMsg"
								style="display: none;">Name is required</span> <span
								id="name_invalid" class="errMsg" style="display: none;">Name
									is invalid</span> <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
							</td>
						</tr>

						<tr class="trField">
							<td class="tdFieldName">Is Group</td>
							<td class="tdFieldInput">
								<table class="tblBool">
									<tr class="trBoolSet">
										<td colspan="2" class="tdBoolSet"><input type="checkbox"
											id="is_group" name="is_group"
											onchange="toggleControls(['description', 'id_parent', 'id_prev_item', 'sound', 'light', 'left_screen', 'right_screen', 'center_screen', 'remark']); toggleHyjackControl(['id_employee', 'id_company']);" />
										</td>
									</tr>
									<!-- 						<tr class="trBool"> -->
									<!-- 							<td class="tdBool"><input type="radio" -->
									<!-- 								id="is_group_true" name="is_group" value="1" -->
									<!-- 								checked="checked" />Yes</td> -->
									<!-- 							<td class="tdBool"><input type="radio" -->
									<!-- 								id="is_group_false" name="is_group" value="0" />No</td> -->
									<!-- 						</tr> -->
								</table></td>
							<td class="tdErrMsg"></td>
						</tr>

						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput"><textarea id="description"
									name="description" rows="5" class="inputTextarea"><%=obj.getDescription()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="description_required"
								class="errMsg" style="display: none;">Description is
									required</span> <span id="description_invalid" class="errMsg"
								style="display: none;">Description is invalid</span> <span
								id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Parent</td>
							<td class="tdFieldInput"><select id="id_parent"
								name="id_parent" class="hyjack">
									<%=HtmlUtil.genModelSelect(
					CacheUtil.getIsGroupAgendaItemList(obj.getIdAgenda()), null)%>
							</select> <%-- 					<input class="inputInt" type="text" id="id_parent" name="id_parent" maxlength="10" value="<%=obj.getIdParent()%>" /> --%>

							</td>
							<td class="tdErrMsg"><span id="id_parent_required"
								class="errMsg" style="display: none;">Parent is required</span>
								<span id="id_parent_invalid" class="errMsg"
								style="display: none;">Id Parent is invalid</span> <span
								id="id_parent_error" class="errMsg"><%=obj.errMsgs.IdParent%></span>
							</td>
						</tr>

						<tr class="trField">
							<td class="tdFieldName">Previousivious Item</td>
							<td class="tdFieldInput"><select id="id_prev_item"
								name="id_prev_item" class="hyjack">
									<%=HtmlUtil.genModelSelect(
					CacheUtil.getSameParentAgendaItemList(obj.getIdParent()),
					null)%>
							</select> <%-- 					<input class="inputInt" type="text" id="id_prev_item" name="id_prev_item" maxlength="10" value="<%=obj.getIdPrevItem()%>" /> --%>

							</td>
							<td class="tdErrMsg"><span id="id_prev_item_required"
								class="errMsg" style="display: none;">Previous Item is
									required</span> <span id="id_prev_item_invalid" class="errMsg"
								style="display: none;">Previous Item is invalid</span> <span
								id="id_prev_item_error" class="errMsg"><%=obj.errMsgs.IdPrevItem%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Employee</td>
							<td class="tdFieldInput"><select id="id_employee"
								name="id_employee" class="hyjack">
									<%=HtmlUtil.genModelSelect(CacheUtil.getEmployeeList(),
					null, obj.getIdEmployee())%>
							</select> <%-- 					<input class="inputInt" type="text" id="id_employee" name="id_employee" maxlength="10" value="<%=obj.getIdEmployee()%>" /> --%>

							</td>
							<td class="tdErrMsg"><span id="id_employee_required"
								class="errMsg" style="display: none;">Employee is
									required</span> <span id="id_employee_invalid" class="errMsg"
								style="display: none;">Employee is invalid</span> <span
								id="id_employee_error" class="errMsg"><%=obj.errMsgs.IdEmployee%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Company</td>
							<td class="tdFieldInput"><select id="id_company"
								name="id_company" class="hyjack">
									<%=HtmlUtil.genModelSelect(CacheUtil.getCompanyList(), null,
					obj.getIdCompany())%>
							</select> <!-- 				<input class="inputInt" type="text" --> <!-- 					id="id_company" name="id_company" maxlength="10" -->
								<%-- 					value="<%=obj.getIdCompany()%>" /> --%></td>
							<td class="tdErrMsg"><span id="id_company_required"
								class="errMsg" style="display: none;">Company is required</span>
								<span id="id_company_invalid" class="errMsg"
								style="display: none;">Id Company is invalid</span> <span
								id="id_company_error" class="errMsg"><%=obj.errMsgs.IdCompany%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Sound</td>
							<td class="tdFieldInput"><textarea id="sound" name="sound"
									rows="5" class="inputTextarea"><%=obj.getSound()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="sound_required"
								class="errMsg" style="display: none;">Sound is required</span> <span
								id="sound_invalid" class="errMsg" style="display: none;">Sound
									is invalid</span> <span id="sound_error" class="errMsg"><%=obj.errMsgs.Sound%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Light</td>
							<td class="tdFieldInput"><textarea id="light" name="light"
									rows="5" class="inputTextarea"><%=obj.getLight()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="light_required"
								class="errMsg" style="display: none;">Light is required</span> <span
								id="light_invalid" class="errMsg" style="display: none;">Light
									is invalid</span> <span id="light_error" class="errMsg"><%=obj.errMsgs.Light%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Left Screen</td>
							<td class="tdFieldInput"><textarea id="left_screen"
									name="left_screen" rows="5" class="inputTextarea"><%=obj.getLeftScreen()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="left_screen_required"
								class="errMsg" style="display: none;">Left Screen is
									required</span> <span id="left_screen_invalid" class="errMsg"
								style="display: none;">Left Screen is invalid</span> <span
								id="left_screen_error" class="errMsg"><%=obj.errMsgs.LeftScreen%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Right Screen</td>
							<td class="tdFieldInput"><textarea id="right_screen"
									name="right_screen" rows="5" class="inputTextarea"><%=obj.getRightScreen()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="right_screen_required"
								class="errMsg" style="display: none;">Right Screen is
									required</span> <span id="right_screen_invalid" class="errMsg"
								style="display: none;">Right Screen is invalid</span> <span
								id="right_screen_error" class="errMsg"><%=obj.errMsgs.RightScreen%></span>
							</td>
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Center Screen</td>
							<td class="tdFieldInput"><textarea id="center_screen"
									name="center_screen" rows="5" class="inputTextarea"><%=obj.getCenterScreen()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="center_screen_required"
								class="errMsg" style="display: none;">Center Screen is
									required</span> <span id="center_screen_invalid" class="errMsg"
								style="display: none;">Center Screen is invalid</span> <span
								id="center_screen_error" class="errMsg"><%=obj.errMsgs.CenterScreen%></span>
							</td>
						</tr>

						<!-- 			<tr class="trField"> -->
						<!-- 				<td class="tdFieldName">Code</td> -->
						<!-- 				<td class="tdFieldInput"><input class="inputText" type="text" -->
						<%-- 					id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" /> --%>
						<!-- 				</td> -->
						<!-- 				<td class="tdErrMsg"><span id="code_required" class="errMsg" -->
						<!-- 					style="display: none;">Code is required</span> <span -->
						<!-- 					id="code_invalid" class="errMsg" style="display: none;">Code -->
						<%-- 						is invalid</span> <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span> --%>
						<!-- 				</td> -->
						<!-- 			</tr> -->


						<!-- 			<tr class="trField"> -->
						<!-- 				<td class="tdFieldName">Id Type</td> -->
						<!-- 				<td class="tdFieldInput"><input class="inputInt" type="text" -->
						<!-- 					id="id_type" name="id_type" maxlength="10" -->
						<%-- 					value="<%=obj.getIdType()%>" /></td> --%>
						<!-- 				<td class="tdErrMsg"><span id="id_type_required" class="errMsg" -->
						<!-- 					style="display: none;">Id Type is required</span> <span -->
						<!-- 					id="id_type_invalid" class="errMsg" style="display: none;">Id -->
						<%-- 						Type is invalid</span> <span id="id_type_error" class="errMsg"><%=obj.errMsgs.IdType%></span> --%>
						<!-- 				</td> -->
						<!-- 			</tr> -->

						<tr class="trField">
							<td class="tdFieldName">Status</td>
							<td class="tdFieldInput"><select id="status" name="status"
								class="dropdownlistStyle">
									<%=HtmlUtil.genEnumSelect(EnumName.AgendaItemStatus, null,
					obj.getStatus())%>
							</select> <!-- 				<input class="inputInt" type="text" --> <!-- 					id="status" name="status" maxlength="10" -->
								<%-- 					value="<%=obj.getStatus()%>" /> --%></td>
							<td class="tdErrMsg"><span id="status_required"
								class="errMsg" style="display: none;">Status is required</span>
								<span id="status_invalid" class="errMsg" style="display: none;">Status
									is invalid</span> <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
							</td>
						</tr>

						<tr class="trField">
							<td class="tdFieldName">Remark</td>
							<td class="tdFieldInput"><textarea id="remark" name="remark"
									rows="5" class="inputTextarea"><%=obj.getRemark()%></textarea>
							</td>
							<td class="tdErrMsg"><span id="remark_required"
								class="errMsg" style="display: none;">Remark is required</span>
								<span id="remark_invalid" class="errMsg" style="display: none;">Remark
									is invalid</span> <span id="remark_error" class="errMsg"><%=obj.errMsgs.Remark%></span>
							</td>
						</tr>

						<!-- 			<tr class="trField"> -->
						<!-- 				<td class="tdFieldName">Notification</td> -->
						<!-- 				<td class="tdFieldInput"><input class="inputInt" type="text" -->
						<!-- 					id="notification" name="notification" maxlength="10" -->
						<%-- 					value="<%=obj.getNotification()%>" /></td> --%>
						<!-- 				<td class="tdErrMsg"><span id="notification_required" -->
						<!-- 					class="errMsg" style="display: none;">Notification is -->
						<!-- 						required</span> <span id="notification_invalid" class="errMsg" -->
						<!-- 					style="display: none;">Notification is invalid</span> <span -->
						<%-- 					id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span> --%>
						<!-- 				</td> -->
						<!-- 			</tr> -->

						<tr class="trInputBottom">
							<td class="trInputBottom" colspan="3">
								<table class="tblSubmit" align="center">
									<tr class="trSubmit">
										<td class="tdSubmit"><input type="submit" value="Submit" />
										</td>
										<td class="tdReset"><input type="reset" value="Reset" />
										</td>
									</tr>
								</table></td>
						</tr>
					</table>
				</form></td>
		</tr>
	</table>
	<br />
	<jsp:include page="agenda.jsp?embedded=true&idAgenda="></jsp:include>
</body>
</html>